﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;

namespace SpotifyRemote
{
	class Server
	{
		public Server()
		{
			_Server = new HttpServer.HttpServer();

			//HttpServer.HttpModules.ControllerModule c = new HttpServer.HttpModules.ControllerModule();
			//c.Add(new Spotify());

			_Server.Add(new Spotify());
		}

		#region Private Members
		private HttpServer.HttpServer _Server;
		private bool _Running;
		#endregion

		#region Properties
		public bool IsRunning
		{
			get { return _Running; }
		}
		#endregion

		public void Start(int port)
		{
			_Server.Start(IPAddress.Any, port);
			_Running = true;
		}

		public void Stop()
		{
			_Server.Stop();
			_Running = false;
		}
	}

	interface IPlugin
	{
		Button[] Buttons { get; }
	}

	struct Button
	{
		public Button(string caption, string actionurl)
		{
			Caption = caption;
			ActionURL = actionurl;
		}

		public string Caption;
		public string ActionURL;
	}

	/*class Spotify : HttpServer.Controllers.RequestController
	{
		public Spotify()
		{
			_API = new SpotifyAPI.SpotifyAPI();
			_API.Initialize();
		}

		SpotifyAPI.SpotifyAPI _API;

		public string PlayPause()
		{
			_API.PlayPause();

			Response.Redirect("/");
			return "";
		}

		public string Prev()
		{
			_API.Previous();

			Response.Redirect("/");
			return "";
		}

		public string Next()
		{
			_API.Next();

			Response.Redirect("/");
			return "";
		}

		public override object Clone()
		{
			return this;
		}

		public Button[] Buttons
		{
			get
			{
				return new Button[] {
					new Button("Play/Pause", "playpause"),
					new Button("Previous", "prev"),
					new Button("Next", "next"),

				};
			}
		}
	}*/
}
